<?php

namespace app\admin\controller;
use think\Controller;
use think\File;
use think\Request;

class Upload extends Base
{
	//图片上传
    public function upload(){
       $file = request()->file('file');
        $file_config = config('upload_image');
       $info = $file->validate($file_config)->move(ROOT_PATH . 'public/uploads/images');
        if($info){
            return json(['code'=>1,'msg'=>'上传成功','data'=>$info->getSaveName()]);
        }else{
            return json(['code'=>0,'msg'=>$file->getError()]);
        }
    }
    //会员头像上传
    public function uploadface(){
        $file_config = config('upload_image');
       $file = request()->file('file');
       $info = $file->validate($file_config)->move(ROOT_PATH . 'public/uploads/face');
       if($info){
           return json(['code'=>1,'msg'=>'上传成功','data'=>$info->getSaveName()]);
        }else{
           return json(['code'=>0,'msg'=>$file->getError()]);
        }
    }
    //图片上传
    public function file(){
        $file_config = config('upload_image');
        $file = request()->file('file');
        $info = $file->validate($file_config)->move(ROOT_PATH . 'uploads/file');
        if($info){
            return json(['code'=>1,'msg'=>'上传成功','data'=>$info->getSaveName()]);
        }else{
            return json(['code'=>0,'msg'=>$file->getError()]);
        }
    }
}